package com.ruoyi.tsjData.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;

import com.ruoyi.tsjData.domain.plat.DataTshjSd;
import com.ruoyi.tsjData.domain.plat.TshjSdParaChange;
import com.ruoyi.tsjData.service.IDataTshjChangeService;
import com.ruoyi.tsjData.service.IDataTshjSdService;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 提升机-速度测试Controller
 * 
 * @author ruoyi
 * @date 2023-10-25
 */
@RestController
@RequestMapping("/tsjData/sd")
@Api(value="提升机-速度测试",tags = "提升机-速度测试接口")
public class DataTshjSdController extends BaseController
{
    @Autowired
    private IDataTshjSdService dataTshjSdService;

    @Autowired
    private IDataTshjChangeService changeService;

    /**
     * 查询提升机-速度测试列表
     */
    @PreAuthorize("@ss.hasPermi('tsjData:sd:list')")
    @GetMapping("/list")
    public TableDataInfo list(DataTshjSd dataTshjSd)
    {
        startPage();
        List<DataTshjSd> list = dataTshjSdService.selectDataTshjSdList(dataTshjSd);
        return getDataTable(list);
    }

    /**
     * 导出提升机-速度测试列表
     */
    @PreAuthorize("@ss.hasPermi('tsjData:sd:export')")
    @Log(title = "提升机-速度测试", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, DataTshjSd dataTshjSd)
    {
        List<DataTshjSd> list = dataTshjSdService.selectDataTshjSdList(dataTshjSd);
        ExcelUtil<DataTshjSd> util = new ExcelUtil<DataTshjSd>(DataTshjSd.class);
        util.exportExcel(response, list, "提升机-速度测试数据");
    }

    /**
     * 获取提升机-速度测试详细信息
     */
    @PreAuthorize("@ss.hasPermi('tsjData:sd:query')")
    @GetMapping(value = "/{sdId}")
    public AjaxResult getInfo(@PathVariable("sdId") Long sdId)
    {
        return success(dataTshjSdService.selectDataTshjSdBySdId(sdId));
    }

    /**
     * 新增提升机-速度测试
     */
    @PreAuthorize("@ss.hasPermi('tsjData:sd:add')")
    @Log(title = "提升机-速度测试", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody DataTshjSd dataTshjSd)
    {
        return toAjax(dataTshjSdService.insertDataTshjSd(dataTshjSd));
    }

    /**
     * 修改提升机-速度测试
     */
    @PreAuthorize("@ss.hasPermi('tsjData:sd:edit')")
    @Log(title = "提升机-速度测试", businessType = BusinessType.UPDATE)
    @PutMapping
    @ApiOperation(value="修改提升机-速度测试")
    public AjaxResult edit(@ApiParam(name="提升机速度数据",value="传入json格式",required=true)@RequestBody DataTshjSd dataTshjSd)
    {
        return toAjax(dataTshjSdService.updateDataTshjSd(dataTshjSd));
    }

    /**
     * 修改提升机-最大速度
     */
    @PreAuthorize("@ss.hasPermi('tsjData:modifySdMax:edit')")
    @Log(title = "提升机-最大速度", businessType = BusinessType.UPDATE)
    @PutMapping("/modifySdMax")
    @ApiOperation(value="修改提升机-最大速度")
    public AjaxResult modifySdMax(@ApiParam(name="提升机速度数据",value="传入json格式",required=true)@RequestBody TshjSdParaChange tshjSdParaChange)
    {
        return AjaxResult.success(changeService.modifySdMax(tshjSdParaChange));
    }

    /**
     * 修改提升机-最大提升距离
     */
    @PreAuthorize("@ss.hasPermi('tsjData:modifyTshjl:edit')")
    @Log(title = "提升机-最大提升距离", businessType = BusinessType.UPDATE)
    @PutMapping("/modifyTshjl")
    @ApiOperation(value="修改提升机-最大提升距离")
    public AjaxResult modifyTshjl(@ApiParam(name="提升机速度数据",value="传入json格式",required=true)@RequestBody TshjSdParaChange tshjSdParaChange)
    {
        return AjaxResult.success(changeService.modifyTshjl(tshjSdParaChange));
    }

    /**
     * 根据id和任务id变更数据状态
     */
    @ApiOperation(value="根据id和任务id变更数据状态")
    @PreAuthorize("@ss.hasPermi('tsjData:sd:editByIdAndDataId')")
    @PostMapping("/editByIdAndDataId/{dataTaskId}/{sdId}")
    @ApiImplicitParams({
            @ApiImplicitParam(paramType="query", name = "dataTaskId", value = "任务id", required = true, dataType = "Long"),
            @ApiImplicitParam(paramType="query", name = "sdId", value = "速度id", required = true, dataType = "Long"),
    })
    public AjaxResult editByIdAndDataId(@PathVariable("dataTaskId")Long dataTaskId, @PathVariable("sdId") Long sdId) {
        return toAjax(dataTshjSdService.updateDataTshjSdBySdId(dataTaskId, sdId));
    }

    /**
     * 删除提升机-速度测试
     */
    @PreAuthorize("@ss.hasPermi('tsjData:sd:remove')")
    @Log(title = "提升机-速度测试", businessType = BusinessType.DELETE)
	@DeleteMapping("/{sdIds}")
    @ApiOperation(value="删除提升机-速度测试")
    public AjaxResult remove(@PathVariable Long[] sdIds)
    {
        return toAjax(dataTshjSdService.deleteDataTshjSdBySdIds(sdIds));
    }
}
